package cn.ht.bootdemo.designmode.facAndmethod.service.impl;

import cn.ht.bootdemo.common.enums.ServiceEnum;
import cn.ht.bootdemo.designmode.facAndmethod.factory.UserServiceStrategyFactory;
import cn.ht.bootdemo.designmode.facAndmethod.service.UserPayService;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

/**
 * @author ht
 * @Description: 普通会员不打折策略实现
 * 实现了InitializingBean接口，容器启动后会调用afterPropertiesSet()方法，往工厂里写入打折策略
 * @date 2020-5-11
 */
@Service
public class NormalPayServiceImpl implements UserPayService, InitializingBean {

    @Override
    public BigDecimal quote(BigDecimal bigDecimal) {
        //TODO 实现业务逻辑
        return new BigDecimal("10");
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        UserServiceStrategyFactory.register(ServiceEnum.COMMON_USER.getValue(),this);
    }
}
